from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Firefox()
# 最大化浏览器窗口
driver.maximize_window()
url = 'file:///C:/Users/TEACHER/Desktop/NSD2405/html/register.html'
driver.get(url)

# 1.获取第1个a元素的内容
text = driver.find_element(By.CSS_SELECTOR, 'a').text
print('第1个a的内容：', text)
# 2.获取用户名文本框大小
size = driver.find_element(By.CSS_SELECTOR, '#user').size
# print('大小：', size)
print('宽度：', size['width'], '高度：', size['height'])
# 3.获取元素的属性值
value = driver.find_element(By.CSS_SELECTOR, '#fw').get_attribute('href')
print('href：', value)
# 4.判断元素是否可见
display = driver.find_element(By.CSS_SELECTOR, 'span').is_displayed()
print('span元素是否可见：', display)
# 5.判断元素是否可用
enable = driver.find_element(By.CSS_SELECTOR, '#yy').is_enabled()
print('复选框是否可用：', enable)
# 6.判断元素（复选框和单选框）是否被选中
qc = driver.find_element(By.CSS_SELECTOR, '#qc')
qc.click()
print('是否被选中：', qc.is_selected())

sleep(3)
driver.quit()